package com.itheima;

import com.itheima.domain.User;
import org.springframework.stereotype.Component;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.servlet.ModelAndView;

import javax.servlet.http.HttpServletRequest;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Controller
@RequestMapping("/user")
public class UserController {


    /*使用了springmvc的注解驱动(一定要加 <mvc:annotation-driven></mvc:annotation-driven>),可以识别@RequestBody,
       @responseBody是对控制器方法进行结果转换,也就是告诉springmvc返回的是数据
       由于返回值是引用类型,自动调用工具提供的类型转换器进行格式转化(Jackson,fastjson,gson)
        @RequestBody 形参注解
     * */
    @RequestMapping(value = "/reg")
    @ResponseBody
    public Map reg(@RequestBody User user){
        System.out.println(user);

        HashMap<String, Object> map = new HashMap<>();
        map.put("flag",true);
        map.put("message","注册成功");

        return map;
    }

}
